package com.md24housecall.net;

import android.text.TextUtils;

import com.md24housecall.util.GlobalConstant;
import com.md24housecall.util.MyConfig;

public class UrlBuilder {

	public static final String HOST_WS = "https://wp-dot-erudite-stratum-347.appspot.com/";
	public static final String HOST_TEST = "http://tele.mobile-solution.org/";
	private static final String HOST=MyConfig.DEBUG? HOST_TEST:HOST_WS;
	public static final String WS_ADD_USER = "ws-user-new?code=%s";
	public static final String WS_CALL_TRACKING=HOST_WS+"ws-call-tracking";
	public static final String GETIMAGEAPIURL=HOST_WS+"ws-media";
	
	public static final String URL_REGISTER_ACCOUNT = "http://md24hco.bizodo.com/f/ynOKUm";
	public static final String URL_GENERATECODE=HOST+"code_controller/check/";
	public static final String URL_GETCATEGORYPARTNER=HOST+"partner_category_controller/getall/";
	public static final String URL_GETPARTNERINFO=HOST+"partner_controller/getall/";
	public static final String URL_GETLISTDOCTOR=HOST+"doctor_controller/getall";
	public static final String URL_GETLISTDOCTORBYCODE=HOST+"doctor_controller/getall_by_code/%s";
	
	/*Start ihealth*/
	private static final String HOST_IHEALTH="https://api.ihealthlabs.com:8443/";
	//start:test
	private static final String HOST_TOKEN_IHEALTH_TEST="http://ihealthlab.mobile-solution.org/developer/";
	private static final String REDIRECT_URL_TEST="http://ihealthlab.mobile-solution.org/developer/callback.php";
	//end:test
		
	//start:release
//	private static final String HOST_TOKEN_IHEALTH_RELEASE="https://wp-dot-erudite-stratum-347.appspot.com/";
//	private static final String REDIRECT_URL_RELEASE="https://wp-dot-erudite-stratum-347.appspot.com/show_login.php";
	private static final String REDIRECT_URL_RELEASE="https://wp-dot-erudite-stratum-347.appspot.com/callback.php";
	//start:release
	
//	private static final String HOST_TOKEN_IHEALTH=MyConfig.DEBUG?HOST_TOKEN_IHEALTH_TEST:HOST_TOKEN_IHEALTH_RELEASE;
	private static final String HOST_TOKEN_IHEALTH=MyConfig.DEBUG?HOST_TOKEN_IHEALTH_TEST:HOST_WS;
	
	public static final String REDIRECT_URL=MyConfig.DEBUG?REDIRECT_URL_TEST:REDIRECT_URL_RELEASE;
	public static final String URL_LOGIN_IHEALTH=HOST_IHEALTH+"OpenApiV2/OAuthv2/login/?redirect_uri=%2fOpenApiV2%2fOAuthv2%2fuserauthorization%2f%3fclient_id%3d"+GlobalConstant.getInstance().CLIENTID+"%26APIName%3dOpenApiBP+OpenApiWeight+OpenApiBG+OpenApiSpO2+OpenApiActivity+OpenApiSleep+OpenApiUserInfo%26response_type%3dcode%26redirect_uri%3d"+REDIRECT_URL+"%3Funique_id%3D";
	public static final String URL_REFRESH_TOKEN_IHEALTH = HOST_IHEALTH
			+ "OpenApiV2/OAuthv2/userauthorization/?client_id="+GlobalConstant.getInstance().CLIENTID+"&client_secret="+GlobalConstant.getInstance().CLIENTSECRET+"&redirect_uri="+REDIRECT_URL+"&refresh_token=%s&response_type=refresh_token";
//	public static final String URL_GETDATA_IHEALTH=HOST_IHEALTH+"openapiv2/user/%s/%s/?client_id="+GlobalConstant.getInstance().CLIENTID+"&client_secret="+GlobalConstant.getInstance().CLIENTSECRET+"&redirect_uri="+REDIRECT_URL+"&access_token=%s&sc=%s&sv=%s&start_time=%s&end_time=%s";
	public static final String URL_GETDATA_IHEALTH=HOST_IHEALTH+"openapiv2/user/%s/%s/?client_id="+GlobalConstant.getInstance().CLIENTID+"&client_secret="+GlobalConstant.getInstance().CLIENTSECRET+"&redirect_uri="+REDIRECT_URL+"&access_token=%s&sc=%s&sv=%s";
	public static final String URL_GETTOKEN_IHEALTH=HOST_TOKEN_IHEALTH+"token.php?unique_id=%s";
	
	public static final String URL_GET_MULTI_IHEALTH=HOST_TOKEN_IHEALTH+"ihealth_controller/get_by_code?code=%s";
	/*End ihealth*/
	
	public static final String URL_DELETE_IHEALTH_ACCOUNT=HOST_TOKEN_IHEALTH+"ihealth_controller/remove?ihealth_id=%s&code=%s";
	public static final String URL_ADD_PATIENT= HOST_WS+"center_controller/addPatient?name=%s&email_address=%s&center_id=%s&skype_name=%s&ihealthUserName=%s&ihealthPassword=%s";
	public static final String URL_GET_PATIENT= HOST_WS+"center_controller/getDetail?id=%s";
	public static final String URL_DELETE_PATIENT= HOST_WS+"center_controller/deletePatient?center_id=%s&patient_id=%s";
	
	public static String buildWSAddUser(String code) {
		if(TextUtils.isEmpty(code))
			throw new IllegalAccessError("buildWSAddUser: code cannot be EMPTY");
		String url = HOST + WS_ADD_USER;
		return String.format(url, code);
	}
	
}
